package com.lagou.seaech.listener;

import com.lagou.seaech.service.SearchService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author Fxz
 * @version 1.0
 * @date 2021-10-06 9:16
 */
@Slf4j
@AllArgsConstructor
@Component
@RabbitListener(queues = "search_add_queue")
public class SpuPutListener {

    private final SearchService searchService;

    @RabbitHandler
    public void addDataToEs(String spuId) {
        log.info("接收到需要上架的商品id:{}", spuId);
        searchService.addDataToEs(spuId);
    }
}
